package son.nt.util;

import android.os.AsyncTask;
import android.util.Log;
import son.nt.entities.Song;

public class UtilInterface {
	protected static final String TAG = "UtilInterface";
	ManualSearchListener listener;
	
	public UtilInterface(){
		Log.v(TAG, "contructor");
	}
	public interface ManualSearchListener{
		public void onGet(Song song);
		public void onError();
	}
	
	public void manualSearch(String s, ManualSearchListener listener2){
		this.listener = listener2;
		AsyncTask<String, Void, Song> SongAsync = new AsyncTask<String, Void, Song>(){
			@Override
			protected void onPreExecute() {
				// TODO Auto-generated method stub
				super.onPreExecute();
			}

			@Override
			protected Song doInBackground(String... params) {
				Log.v(TAG, "doInBackground");
				Song songResult = new Song();
				songResult.setTitle("sonnt title");
				songResult.setArtist("sonnt artist");
				return songResult;
			}
			@Override
			protected void onPostExecute(Song result) {
				super.onPostExecute(result);
				if(result != null){
					Log.v(TAG, "onpost:" + result.getTitle());
					listener.onGet(result);
				}else{
					listener.onError();
				}
			}
			
		};
		SongAsync.execute(s);
	}

}
